Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix Strings (Trie): Removing lines of code that resulted duplicates #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thenishantgiri
Copy link

The solution provided in the GitHub repo might need some correction!

we have a dfs function, which has a case for handling the current node isTerminal and if it is terminal, then we're adding the word in the vector that contains our result.

we have a find function that checks whether our tree contains the prefix; if it does, then it calls the dfs function and passes args (address of the last prefix char, address of vector, and word, i.e., the prefix itself)

In the find function, we have also added a check before calling the dfs; if temp/curr is a Terminal, then add it to the vector. line 58-60

Conclusion: There were two checks for the same purpose, and if we pass the same temp, it will repeat the string in the result vector.

Case: if the prefix is also present in the vector word.

Fix: Please remove lines 58-60 or merge my pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant